-
-
Notifications
You must be signed in to change notification settings - Fork 17.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CLN: Use generators instead of lists in built-in Python functions #18276
Conversation
Codecov Report
@@ Coverage Diff @@
## master #18276 +/- ##
==========================================
- Coverage 91.4% 91.38% -0.02%
==========================================
Files 164 164
Lines 49878 49878
==========================================
- Hits 45590 45581 -9
- Misses 4288 4297 +9
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #18276 +/- ##
==========================================
- Coverage 91.4% 91.38% -0.02%
==========================================
Files 164 164
Lines 49878 49878
==========================================
- Hits 45590 45581 -9
- Misses 4288 4297 +9
Continue to review full report at Codecov.
|
@mroeschke thanks. can you add a linting check in |
does this have any perf impact ? |
I ran one full asv and two asvs for Sure I can include this check in |
thanks
would be great |
I don't thing you would expect to see any difference in asv. I think this is mainly about code style / redundancy. Certainly given that, apparently (just tried it out, didn't expect this), with small lists it can actually be a bit faster using a list comprehension instead of generator (for bigger ones there is a clear difference though):
(and the cases in our code typically are small numbers, eg looping of the axes of a DataFrame (thus 2)) |
git diff upstream/master -u -- "*.py" | flake8 --diff
Pass generators in built-in Python functions instead of passing in a list, e.g
any([value for value in iterator])
-->any(value for value in iterator)